package com.example.sm_project01;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteDatabase.CursorFactory;
import android.database.sqlite.SQLiteOpenHelper;

public class DBHelper extends SQLiteOpenHelper {
	public DBHelper(Context context) {
		super(context, "SMS.db", null, 1);
	}

	public void onCreate(SQLiteDatabase db) {
		db.execSQL("CREATE TABLE sms ( _id TEXT PRIMARY KEY, " +
				"name TEXT NOT NULL, status TEXT, organization TEXT, phone TEXT NOT NULL, " +
				"groupname TEXT, custom TEXT, msg TEXT );");
		/* 테이블 인스턴스
		_id TEXT PRIMARY KEY,
		name TEXT NOT NULL,
		status TEXT,
		organization TEXT,
		phone TEXT NOT NULL,
		groupname TEXT,
		custom TEXT,
		msg TEXT
		*/
		
		db.execSQL("CREATE TABLE smstemplate ( _id TEXT PRIMARY KEY, " + "msg TEXT );");
		/* 테이블 인스턴스
		_id TEXT PRIMARY KEY,
		msg TEXT
		*/
		
		db.execSQL("CREATE TABLE mail ( _id TEXT PRIMARY KEY, " +
				"name TEXT NOT NULL, status TEXT, organization TEXT, mail TEXT NOT NULL, " +
				"groupname TEXT, custom TEXT, title TEXT, msg TEXT );");
		/* 테이블 인스턴스
		_id TEXT PRIMARY KEY,
		name TEXT NOT NULL,
		status TEXT,
		organization TEXT,
		mail TEXT NOT NULL,
		groupname TEXT,
		custom TEXT,
		title TEXT,
		msg TEXT
		*/
		
		db.execSQL("CREATE TABLE mailtemplate ( _id TEXT PRIMARY KEY, " + "title TEXT, msg TEXT );");
		/* 테이블 인스턴스
		_id TEXT PRIMARY KEY,
		title TEXT,
		msg TEXT
		*/
		
		db.execSQL("CREATE TABLE configure ( mail TEXT, password TEXT );" );
	}

	public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
		db.execSQL("DROP TABLE IF EXISTS sms");
		onCreate(db);
	}
}
